/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.company.regis.db.entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author totoland
 */
@Entity
@Table(name = "REG_USER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RegUser.findAll", query = "SELECT r FROM RegUser r")})
public class RegUser implements Serializable {

    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @GeneratedValue(generator = "seqRegUser")
    @SequenceGenerator(name = "seqRegUser", sequenceName = "REG_USER_SEQ")
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "USER_ID")
    private Long userId;
    @Basic(optional = false)
    @Column(name = "USER_NAME")
    private String userName;
    @Basic(optional = false)
    @Column(name = "USER_PASSWORD")
    private String userPassword;
    @Column(name = "FIRST_NAME")
    private String firstName;
    @Column(name = "LAST_NAME")
    private String lastName;
    @Column(name = "GENDER")
    private BigInteger gender;
    @Column(name = "USER_GROUP")
    private BigInteger userGroup;
    
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "regUser",targetEntity = RegAddress.class,fetch = FetchType.EAGER)
    private RegAddress regAddress;

    public RegUser() {
    }

    public RegUser(Long userId) {
        this.userId = userId;
    }

    public RegUser(Long userId, String userName, String userPassword) {
        this.userId = userId;
        this.userName = userName;
        this.userPassword = userPassword;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public BigInteger getGender() {
        return gender;
    }

    public void setGender(BigInteger gender) {
        this.gender = gender;
    }

    public BigInteger getUserGroup() {
        return userGroup;
    }

    public void setUserGroup(BigInteger userGroup) {
        this.userGroup = userGroup;
    }

    public RegAddress getRegAddress() {
        return regAddress;
    }

    public void setRegAddress(RegAddress regAddress) {
        this.regAddress = regAddress;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (this.userId != null ? this.userId.hashCode() : 0);
        hash = 67 * hash + (this.userName != null ? this.userName.hashCode() : 0);
        hash = 67 * hash + (this.userPassword != null ? this.userPassword.hashCode() : 0);
        hash = 67 * hash + (this.firstName != null ? this.firstName.hashCode() : 0);
        hash = 67 * hash + (this.lastName != null ? this.lastName.hashCode() : 0);
        hash = 67 * hash + (this.gender != null ? this.gender.hashCode() : 0);
        hash = 67 * hash + (this.userGroup != null ? this.userGroup.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RegUser other = (RegUser) obj;
        if (this.userId != other.userId && (this.userId == null || !this.userId.equals(other.userId))) {
            return false;
        }
        if ((this.userName == null) ? (other.userName != null) : !this.userName.equals(other.userName)) {
            return false;
        }
        if ((this.userPassword == null) ? (other.userPassword != null) : !this.userPassword.equals(other.userPassword)) {
            return false;
        }
        if ((this.firstName == null) ? (other.firstName != null) : !this.firstName.equals(other.firstName)) {
            return false;
        }
        if ((this.lastName == null) ? (other.lastName != null) : !this.lastName.equals(other.lastName)) {
            return false;
        }
        if (this.gender != other.gender && (this.gender == null || !this.gender.equals(other.gender))) {
            return false;
        }
        if (this.userGroup != other.userGroup && (this.userGroup == null || !this.userGroup.equals(other.userGroup))) {
            return false;
        }
        return true;
    }

    
    
    @Override
    public String toString() {
        return "RegUser{" + "userId=" + userId + ", userName=" + userName + ", userPassword=" + userPassword + ", firstName=" + firstName + ", lastName=" + lastName + ", gender=" + gender + ", userGroup=" + userGroup + ", regAddress=" + regAddress + '}';
    }

}
